package org.ljy.springblog.service;

import org.ljy.springblog.mapper.BlogInfoMapper;
import org.ljy.springblog.model.BlogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogService {
    @Autowired
    private BlogInfoMapper blogInfoMapper;
    //1.获取所有博客
    public List<BlogInfo> getBlogList() {
        return blogInfoMapper.selectAllBlogInfo();
    }

    //2.根据博客id获取博客详情页
    public BlogInfo getBlogById(Integer id) {
        return blogInfoMapper.selectBlogInfoById(id);
    }

    //3.发布博客
    public Integer addBlog(BlogInfo blogInfo) {
        return blogInfoMapper.insertBlogInfo(blogInfo);
    }

    //4.更新博客
    public Integer updateBlog(BlogInfo blogInfo) {
        return blogInfoMapper.updateBlogInfo(blogInfo);
    }

    //5.删除博客
    public Integer deleteBlog(BlogInfo blogInfo) {
        return blogInfoMapper.updateBlogInfoById(blogInfo);
    }

}
